﻿<UserControl x:Class="ScrumFactory.ProjectsList.ProjectsList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             
             xmlns:SF="clr-namespace:ScrumFactory;assembly=ScrumFactory"                          
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
             
             xmlns:SF_CompViewModel="clr-namespace:ScrumFactory.Composition.ViewModel;assembly=ScrumFactory.Composition"
             
             
             xmlns:props="clr-namespace:ScrumFactory.ProjectsList.Properties"
             
             mc:Ignorable="d" 
             x:Name="thisView"

             HorizontalAlignment="Stretch"
             

             SF_Comp:CommandBehavior.RoutedEventName="Loaded"
             SF_Comp:CommandBehavior.TheCommandToRun="{Binding LoadOnceProjectListCommand}"
             
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.Resources>

        <ObjectDataProvider  x:Key="projectFilterList" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="SF_CompViewModel:ProjectStatusFilter"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>


        <DataTemplate x:Key="projectDataTemplate">

            <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>                        
                    </Grid.RowDefinitions>
                    <Image
                        Grid.Column="0" Grid.RowSpan="3"                        
                        DataContext="{Binding Status,Converter={StaticResource EnumToShortConverter}, ConverterParameter={x:Type SF:BacklogItemStatus}}"
                        VerticalAlignment="Top"
                        Style="{StaticResource ProjectStatusImage}"/>                    
                    <DockPanel Grid.Column="1" Grid.Row="0">
                    <TextBlock Text="{Binding ProjectName}"
                               DockPanel.Dock="Left" TextWrapping="Wrap" Margin="0,0,10,0" MaxWidth="150"
                               FontSize="{StaticResource BigFontSize}" Foreground="{StaticResource TitleTextBrush}" />
                    <TextBlock Text="{Binding ProjectNumber}" HorizontalAlignment="Right" DockPanel.Dock="Right" FontSize="{StaticResource BigFontSize}" Foreground="{StaticResource SubTextBrush}" Margin="3,0,3,0"/>
                    </DockPanel>
                    <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding ClientName}" Foreground="{StaticResource SubTextBrush}" />                    
                </Grid>
            
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            
            <TextBox
                Margin="0,5,0,0"
                Grid.Row="0"
                Grid.ColumnSpan="2"                                
                Text="{Binding SearchFilterText, UpdateSourceTrigger=PropertyChanged}"
                Style="{StaticResource SearchTextBox}"
                ToolTip="{x:Static props:Resources.Search}"
                HorizontalAlignment="Stretch"/>
            <TextBlock
                Grid.Row="1" Grid.Column="0"                
                Style="{StaticResource LabelTextBlock}"
                Text="{x:Static props:Resources.At}"/>
            <ComboBox
                Grid.Row="1" Grid.Column="1"                            
                SelectedItem="{Binding StatusFilter}"                        
                ItemsSource="{Binding Source={StaticResource projectFilterList}}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding ., Converter={StaticResource LocalizeConverter},ConverterParameter='ScrumFactory.ProjectsList.ProjectsList,ScrumFactory.ProjectsList'}" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox> 
        </Grid>
        <ListBox
            x:Name="projectListBox"
            Grid.Row="1"
            
            ItemContainerStyle="{StaticResource HorizontalLineDividedListBoxItem}"                      
            ItemsSource="{Binding FilteredProjects}" SelectionMode="Single"
            SelectedItem="{Binding SelectedProject}"            
            Background="Transparent"
            BorderThickness="0"
            HorizontalContentAlignment="Stretch"                                        
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Auto"
                        
            ItemTemplate="{StaticResource projectDataTemplate}">            
        </ListBox>

        <ContentControl Grid.Row="1"                                                
                        Style="{StaticResource LoadingAnimationContent}"/>
            

        <Grid
            Grid.Row="1"
            HorizontalAlignment="Left">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Image Grid.Column="0" Source="/Images/information.png"  Width="16" Height="16" Stretch="Uniform" Margin="3" VerticalAlignment="Top" />
            <TextBlock Grid.Column="1" TextWrapping="Wrap" >
                <TextBlock TextWrapping="Wrap" Text="{x:Static props:Resources.No_projects_were_found}"/><LineBreak/>
                <TextBlock TextWrapping="Wrap" Margin="0,10,0,0" Foreground="{StaticResource SubTextBrush}" Text="{x:Static props:Resources.No_projects_were_found_tip}"/>
            </TextBlock>
            <Grid.Style>
                <Style>
                    <Setter Property="Grid.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=projectListBox, Path=HasItems}" Value="False"/>
                                <Condition Binding="{Binding IsLoadingData}" Value="False"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Grid.Visibility" Value="Visible"/>
                        </MultiDataTrigger>                        
                    </Style.Triggers>
                </Style>
            </Grid.Style>
        </Grid>

    </Grid>
        
        
        
        
  
  
</UserControl>
